//
// Created by Xu Xiao on 2022/9/10.
//

#include "Sln_N_Q2560.h"

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <unordered_map>

#ifndef ALGORITHM_22_1_SOLUTION0916_H
#define ALGORITHM_22_1_SOLUTION0916_H

using namespace std;

class Solution0916 {
public:
    static void M_Q2559() {
        int a[7]{}, sum, m;
        int _22[4] = {9, 5, 3, 1};
        while (true) {
            sum = 0;
            for (int i = 1; i < 7; i++) {
                cin >> a[i];
                sum += a[i];
            }
            if (!sum) break;
            m = a[6] + a[5] + a[4] + ceil(1.0 * a[3] / 4);
            int _vl22 = a[4] * 5 + _22[a[3] % 4];
            if (a[2] > _vl22) {
                m += ceil((1.0 * a[2] - _vl22) / 9);
            }
            int _vl11 = m * 36 - a[6] * 36 - a[5] * 25 - a[4] * 16 - a[3] * 9 - a[2] * 4;
            if (a[1] > _vl11) {
                m += ceil(1.0 * (a[1] - _vl11) / 36);
            }
            cout << m << endl;
        }
    }

    static void N_Q2560() {
        new Sln_N_Q2560();
    }

    static void O_Q2561() {
        string src, dst;
        int miles;
        char cls;
        while (cin >> src && src != "#") {
            int sum = 0;
            while (src != "0") {
                cin >> dst >> miles >> cls;
                if (cls == 'F') {
                    sum += miles * 2;
                } else if (cls == 'B') {
                    sum += round(miles * 1.5);
                } else if (cls == 'Y') {
                    sum += max(miles, 500);
                }
                cin >> src;
            }
            cout << sum << endl;
        }
    }

    static void P_Q2562() {//有点问题，能AC，但事实上丢掉了一部分空瓶子
        int n, sum = 0;
        while (cin >> n) {
            while (n >= 3) {
                sum += (n - n % 3);
                n = n / 3 + n % 3;
            }
            if (n == 2) sum += 3;
            else sum += n;
            cout << sum << endl;
            sum = 0;
        }
    }

    static void P_Q2562_2() {
        int n, sum = 0;
        while (cin >> n) {
            int emptyBottles = 0;
            while (n >= 3) {
                sum += (n - n % 3);
                int _n = n;
                n = (n - n % 3 + emptyBottles) / 3 + n % 3;
                emptyBottles = (_n - _n % 3 + emptyBottles) % 3;
            }
            if (n == 2) sum += 3;
            else if (n == 1) {
                sum++;
                if (emptyBottles >= 1) {
                    sum++;
                }
            } else if (n == 0) {
                if (emptyBottles == 2) sum++;
            }
            cout << sum << endl;
            sum = 0;
        }
    }

    static void Q_Q2563() {
        ll a, b, cases = 1;
        while (scanf("%lld %lld", &a, &b)) {
            if (a < 0 || b < 0) break;
            int ans = 1;
            ll A = a;
            while (a != 1) {
                if (a % 2 == 1) a = a * 3 + 1;
                else a /= 2;
                if (a > b) break;
                ans++;
            }
            printf("Case %lld: A = %lld, limit = %lld, number of terms = %d\n", cases, A, b, ans);
            cases++;
        }
    }

    static void R_Q2564() {
        int N;
        cin >> N;
        string cards[55]{}, words[55]{};
        string output[55]{};
        bool flag[55];
        memset(flag, 0, sizeof(flag));
        int i;
        for (i = 0; i < N; i++) {
            cin >> cards[i] >> words[i];
        }
        cin.get();
        int _ptr = 0;
        for (i = 0; i < N; i++) {
            int _len = words[i].length();
            while (_len) {
                if (flag[_ptr]) {
                    _ptr = (_ptr + 1) % N;
                    continue;
                } else {
                    _len--;
                    _ptr = (_ptr + 1) % N;
                }
            }
            output[(_ptr - 1 + N) % N] = cards[i];
            flag[(_ptr - 1 + N) % N] = true;
        }
        for (i = 0; i < N; i++) {
            cout << output[i] << " ";
        }
    }
};


#endif //ALGORITHM_22_1_SOLUTION0916_H
